//设置令牌
axios.get('/student/list', {
    // headers: {
    //     Authorization: localStorage.getItem('token7')
    // }

})
    .then(result => {
        //console.log(result);
    })

//退出按钮功能
/* 
1.绑定按钮点击事件
2.remove掉token
3.返回登录页面

 */

const logout = document.querySelector('.logout a');//退出按钮
const Menuone = document.querySelectorAll('.nav>li>a'); //一级菜单的 控制面板和学员管理
const Menutwo = document.querySelectorAll('.nav ul a');//获取二级菜单
const init = document.querySelector('.init');//初始化按钮

logout.addEventListener('click', function (e) {
    //提示框
    if (confirm('确定要退出吗')) {
        //移除token
        localStorage.removeItem('token7')
        //返回login页面
        location.href = 'login.html'
    }

})

//一级菜单点击事件
//绑点点击事件
Menuone.forEach(one => {
    one.addEventListener('click', function () {
        //console.log(211);
        //小箭头旋转
        one.querySelector('.toggle').classList.toggle('toggleone')
        //show的类 隐藏或展示
        one.nextElementSibling.classList.toggle('show')

    })
})

//二级菜单点击事件
Menutwo.forEach(two => {
    two.addEventListener('click', function () {

        //移除旧的类
        document.querySelector('.nav ul a.active').classList.remove('active')
        //给当前点击的添加新的类
        this.classList.add('active')
    })
})


//初始化
init.addEventListener('click', function () {
    axios.get('/init/data')
        .then(result => {
            console.log(result);
        })
})


